<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#backBtn").click(function(){
			history.go(-1);
		});
		
		$("#registerF").submit(function(){
			if($("#id1").val()==""||$("#password1").val()==""||$("#ssn1").val()==""
					||$("#nick1").val()==""||$("#name1").val()==""||$("#address1").val()==""
					||$("#tel1").val()=="")
				{
				alert("공백없이 입력하시오");
				return false;
				}	
		}); //registerF submit
		
		$("#idCheckBtn").click(function()
		{
			$.ajax({
				type : "post",
				url : "${initParam.root}/checkMemberById.do",
				data:"id="+$("#id1").val(),
				datatype:"json",
				success:function(data){
					if(data==true)
						{
						alert("사용가능한 아이디 입니다");
						}
					else
						{
						alert("사용 불가능한 아이디 입니다");
						}			
				}
			});
			
		});//idChekBtn click
		
		$("#nickCheckBtn").click(function()
				{
					$.ajax({
						type : "post",
						url : "${initParam.root}/checkMemberByNick.do",
						data:"nick="+$("#nick").val(),
						datatype:"json",
						success:function(data){
							if(data==true)
								{
								alert("사용가능한 닉네임 입니다");
								}
							else
								{
								alert("사용 불가능한 닉네임 입니다");
								}
							
							
						
						}
					});
					
				});
	});
	
	
	
</script>
<title>회 원 가 입</title>
</head>
<body>
<center>
<h1>회 원 가 입</h1>
<form id="registerF" action="${initParam.root}/register.do" method="post">
아이디 : <input type="text" id="id1" name="id">&nbsp;&nbsp;<input type="button" id="idCheckBtn" value="중복확인"> <Br> 
패스워드 : <input type="password" id="password1" name="password"><br>
SSN : <input type="password" id="ssn1" name="ssn"><br> 
닉네임 : <input type="text" id="nick1" name="nick"> &nbsp;&nbsp;<input type="button" id="nickCheckBtn" value="중복확인"><br> 
이름 : <input type="text" id="name1" name="name"><br>
주소 : <input type="text" id="address1" name="address"><br>
전화번호 : <input type="text" id="tel1" name="tel"><br>
<input type="submit" value="가입하기">&nbsp;&nbsp;&nbsp;
 <input id="backBtn" type="button" value="뒤로가기">
 <Br>

</form>
</center>
</body>
</html>